
package com.kanjian.music.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.kanjian.music.fragment.FeedFragment;
import com.kanjian.music.fragment.FMFragment;
import com.kanjian.music.fragment.RecommendFragment;
import com.kanjian.music.fragment.TopListFragment;

/**
 * 音乐分栏下 ViewPagerAdapter
 * 
 * @author xuyanjun@kanjian.com
 */
public class MusicPagerAdapter extends FragmentPagerAdapter {

    private static final String[] TITLE = {
        "发现", "榜单", "电台", "邂逅"
    };

    public Fragment[] mFragments = {
            new RecommendFragment(), new TopListFragment(), new FMFragment(),
            new FeedFragment()
    };

    public MusicPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        return mFragments[position];
    }

    @Override
    public void setPrimaryItem(ViewGroup container, int position, Object object) {
        super.setPrimaryItem(container, position, object);
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return TITLE[position];
    }

    @Override
    public int getCount() {
        return mFragments.length;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        System.out.println(container);
        return super.instantiateItem(container, position);
    }

}
